<extend name="Public/base"/>
<block name="body">
    <div class="main-title">
        <h2>{$title}</h2>
    </div>
    <div ng-controller="ProCtrl"  ng-cloak class="ng-cloak" ng-init="init('{$spec}')">
        <form action="{:U()}" id="proform" method="post" enctype="multipart/form-data" class="form-horizontal">
            <div class="form-item">
                <label class="item-label">货别</label>
                <div class="controls">
                    <select select2 ng-change="classifySelect(classifyIndex)" class="text" ng-model="classifyIndex" required/>
                    <option ng-repeat="ca in classifies" value="{{($index)}}">
                        {{ca.classify}}
                    </option>
                    </select>
                    <input type="text" class="text input-large hide" name="classify"  ng-model="product.classify"  />
                    <input type="text" class="text input-large hide" name="classify_no" ng-model="product.classify_no"    />
                </div>
            </div>
            <div class="form-item">
                <label class="item-label" >水果名</label>
                <div class="controls">
                    <select select2 class="text" id="pname-select" ng-change="fruitNameSelect(fruitNameIndex)" ng-model="fruitNameIndex">
                        <option></option>
                        <option ng-repeat="apa in furitNames" value="{{($index)}}">{{apa.pname}}[{{apa.fruit_classify}}]</option>
                    </select>
                    <input type="text" class="hide" name="fruit_classify_no" ng-model="product.fruit_classify_no" />
                    <input type="text" class="hide" name="fruit_classify" ng-model="product.fruit_classify"  />
                    <input type="text" class="hide" name="pname" ng-model="product.pname"  />
                    <input type="text" class="hide" name="pname_no" ng-model="product.pname_no" />
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">规格<span class="text-danger small">(例子：20斤/箱)</span></label>
                <div class="controls">
                    <input type="text" class="text" name="spec" ng-model="product.spec"/>
                    <span ng-show="recommentUnitArr.length>0">建议单位</span>
                    <span class="text-primary glyphicon glyphicon-question-sign" title="20斤/箱，斤为基础单位，箱为贮存单位"></span>
                    <span ng-repeat="recommentUnit in recommentUnitArr" ng-click="unitclick(recommentUnit)" class="btn btn-primary" style="padding: 4px;">
                        {{recommentUnit}}
                    </span>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">规格编号<span class="text-danger small">（自动生成）</span></label>
                <div class="controls">
                    <input type="text" class="text" name="spec_no" ng-model="product.spec_no" placeholder="数据完整时自动生成" required readonly/>
                </div>
            </div>
            <div ng-if="product.classify_no==2">
                <div class="form-item">
                    <label class="item-label">人工费</label>
                    <div class="controls">
                        <input type="text" class="text" name="process_fee" ng-model="process_fee" placeholder="加工费" required />
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">快递费</label>
                    <div class="controls">
                        <input type="text" class="text" name="express_fee" value="2.5" placeholder="快递费" required />
                    </div>
                </div>
                <div class="form-item">
                    <button type="button" ng-click="moreSubpro()" class="btn btn-primary">添加耗材</button>
                    <table class="table" style="width: 60%">
                        <tr ng-repeat="sub in subpro">
                            <th>
                                耗材[单价]
                            </th>
                            <td>
                                <select select2 class="form-control input-3x" name="subproId[]">
                                    <option ng-repeat="subproduct in subproductList" value="{{subproduct.BIN}}">{{subproduct.pname}}[{{subproduct.unitprice}}元]</option>
                                </select>
                            </td>
                            <th>耗材数</th>
                            <td>
                                <input type="number" name="subproNum[]"  ng-model="sub.subproNum" class="input-3x form-control"/>
                            </td>
                            <th>包装类型</th>
                            <td>
                                <select name="subproType[]" class="form-control input-2x">
                                    <option value="1" selected>内包装</option>
                                    <option value="2">外包装</option>
                                </select>
                            </td>
                            <td>
                                <a class="btn btn-primary" ng-click="removeSubpro($index)">-</a>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <br/>
            <div class="form-item">
                <button class="btn submit-btn "  id="submit" type="submit" target-form="form-horizontal">确 定</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1);
                        return false;">返 回</button>
            </div>

        </form>
    </div>
</block>

<block name="script">
    <script type="text/javascript" src="__JS__/material.js"></script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Material/productmanage')}');
    </script>
</block>
